﻿using System;
using System.Drawing;

namespace Lant.Net
{
	public abstract class PukeInfo
	{
		public PukeInfo()
		{ }
		/// <summary>
		/// 卡片资源文件
		/// </summary>
		public Image Card;
		public int CardWidth;
		public int CardHeight;
		/// <summary>
		/// 卡片尺寸
		/// </summary>
		public Size CardSize { get { return new Size(this.CardWidth, this.CardHeight); } }
		/// <summary>
		/// 每张牌的X间隔
		/// </summary>
		public int CardSpaceX;
		/// <summary>
		/// 每张牌的Y间隔
		/// </summary>
		public int CardSpaceY;
		/// <summary>
		/// 偏移量X
		/// </summary>
		public int OffsetX;
		/// <summary>
		/// 偏移量Y
		/// </summary>
		public int OffsetY;
		/// <summary>
		/// 获取卡片的位置
		/// </summary>
		/// <param name="cardIndex"></param>
		/// <returns></returns>
		internal virtual Point GetCardLocation(int cardIndex)
		{
			Point point = new Point();
			point.X = cardIndex % 13 * (this.CardWidth + this.CardSpaceX);
			point.Y = cardIndex / 13 * (this.CardHeight + this.CardSpaceY);
			return point;
		}
		internal virtual int GetCardNumber(int cardIndex)
		{
			int tempNumber = (cardIndex + 1) % 13;
			int tempSign = cardIndex / 13;
			if (tempSign == 4 && tempNumber == 1)
				tempNumber = 14;
			else if (tempSign == 4 && tempNumber == 2)
				tempNumber=15;
			return tempNumber == 0 ? 13 : tempNumber;
		}
		public virtual string GetCardNumberDisplay(int cardNumber)
		{
			string display = "未知";
			switch (cardNumber)
			{
				case 1:
					display = "A";
					break;
				case 11:
					display = "J";
					break;
				case 12:
					display = "Q";
					break;
				case 13:
					display = "K";
					break;
				case 14:
					display = "母";
					break;
				case 15:
					display = "公";
					break;
				default:
					display = cardNumber.ToString();
					break;
			}
			return display;
		}
		public virtual string GetCardSignDisplay(int cardSign)
		{
			string sign = "未知";
			switch (cardSign)
			{
				case 0:
					sign = "方块";
					break;
				case 1:
					sign = "梅花";
					break;
				case 2:
					sign = "黑桃";
					break;
				case 3:
					sign = "红桃";
					break;
				case 4:
					sign = "鬼";
					break;
				default:
					break;
			}
			return sign;
		}
		internal virtual int GetCardSign(int cardIndex)
		{
			return cardIndex / 13;
		}
	}
}
